import request from '@/utils/request'
import { getToken, getAppId, nowTime, getSign, getBaseURL } from '@/utils/auth'

export function paginate(form, page, page_size) {
  return request({
    url: '/api/pajx/batch/paginate/update/cardsn',
    method: 'post',
    data: {
      page_num: page,
      page_size: page_size,
      hxy_scl_id: form.hxy_scl_id
    }
  })
}

export function save(form) {
  return request({
    url: '/api/pajx/batch/save',
    method: 'post',
    data: {
      hxy_scl_id: form.hxy_scl_id,
      task_type: form.task_type,
      file_ori_name: form.file_ori_name,
      file_path: form.file_path
    }
  })
}

export function exportFail(task_id) {
  const data = {
    task_id: task_id
  }
  data['app_id'] = getAppId()
  data['timestamp'] = nowTime()
  data['token'] = getToken()
  data['sign'] = getSign(data)
  let url = getBaseURL() + '/api/pajx/batch/export/fail?'
  for (const i in data) {
    url += i + '=' + data[i] + '&'
  }
  return url
}

export function download(task_id) {
  const data = {
    task_id: task_id
  }
  data['app_id'] = getAppId()
  data['timestamp'] = nowTime()
  data['token'] = getToken()
  data['sign'] = getSign(data)
  let url = getBaseURL() + '/api/pajx/batch/download?'
  for (const i in data) {
    url += i + '=' + data[i] + '&'
  }
  return url
}
